<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://celepar.pr.gov.br/taglibs/html-2.0" prefix="grid"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<jsp:useBean id="agora" class="java.util.Date" />
<html:form action="/pesquisaLogGrupoSistema.do">
<html:hidden property="acao" value=""/>
<div id="conteudo_corpo">
	<h2>Informe os dados de Filtro para a Pesquisa</h2>
	<table class="form_tabela" cellspacing="0">
		
		<tr>
			<td class="form_label">Grupo</td>
			<td valign="middle">
				<html:hidden property="codGrupo"/>
				<html:text property="nomeGrupo" disabled="true" size="50"/>&nbsp;
                <img src="<%=request.getContextPath()%>/images/icon_localizar.png" onclick="clearGrupo();window_open('<%=request.getContextPath()%>/popupGrupo.do?acao=popup','popup','scrollbars=yes,resizable=yes,width=500,height=450')" /> 
			</td>
		</tr>
		<c:if test="${!empty requestScope.listaSistemas}">
			<tr>
				<td class="form_label">Sistema</td>
				<td>
					<html:select property="codSistema" >
						<html:option value="">Todos os Sistemas</html:option>
						<html:options collection="listaSistemas" property="codSistema" labelProperty="nome" />
					</html:select>
				</td>
			</tr>
  		</c:if>
  		<tr> 
        	<td class="form_label" height="30">Autor </td>
        	<td>
          		<html:hidden property="codAutor"/>	
          		<html:text property="nomeAutor" size="24" maxlength="60" disabled="true" />
          		<img src="<%=request.getContextPath()%>/images/icon_localizar.png" onclick="clearAutor();window_open('<%=request.getContextPath()%>/popupUsuario.do?exibirInativos=true','popup','scrollbars=yes,resizable=yes,width=500,height=450')" />
          	</td>
        </tr>
		<tr>
			<td class="form_label">Data Inicial</td>
			<td>
				<html:text property="dataInicial" size="10" maxlength="10" styleId="dataInicial"
                	onkeyup="javascript:MascaraData(this,event)"/>
				<img src="<%=request.getContextPath()%>/images/icone_calendario.gif" width="16" height="15" id="icone"
					onclick="Calendario(document.getElementById('dataInicial'),this.id);" />
				Ex: <fmt:formatDate value="${agora}" />
			</td>
		</tr>
		<tr>
			<td class="form_label">Data Final</td>
			<td>
				<html:text property="dataFinal" size="10" maxlength="10" styleId="dataFinal"
                	onkeyup="javascript:MascaraData(this,event)"/>
				<img src="<%=request.getContextPath()%>/images/icone_calendario.gif" width="16" height="15" id="icone"
					onclick="Calendario(document.getElementById('dataFinal'),this.id);" />
				Ex: <fmt:formatDate value="${agora}" />
			</td>
		</tr>
		<tr>
	   		<td class="form_label">Limite</td>
	   		<td>
	    		<html:select property="limite">
	     			<c:if test="${!empty requestScope.listaValoresLimite}">
	    				<c:forEach var="valor" items="${listaValoresLimite}">
                  			<html:option value="${valor.value}"><c:out value="${valor.label}"/></html:option>
                  		</c:forEach>
                  	</c:if>
	    		</html:select>
	   		</td>
	  	</tr>
	</table>
	<hr />
	<div align="center">
		<c:if test="${!empty requestScope.listaSistemas}">
			<html:button property="" value="Pesquisar"      styleClass="form_botao" onclick="javascript:AoClicarPesquisar();"/>
		</c:if>
		<html:button property="" value="Tela Principal" styleClass="form_botao" onclick="javascript:AoClicarPrincipal();"/>
	</div>
</div>

<c:if test="${!empty pagina}">
	<div id="conteudo_corpo">
		<grid:table  classLinha1="list_cor_sim" classLinha2="list_cor_nao">
			<grid:lista bean="${pagina}" atributoId="codLog" />
			<grid:campo atributo="grupo.nome" label="Grupo"  align="center" />
			<grid:campo atributo="sistema.nome" label="Sistema"  align="center" />
			<grid:campo atributo="autor.nome" label="Nome Autor"  align="center" /> 
			<grid:campo atributo="autor.login" label="Login Autor"  align="center" /> 
	    	<grid:campo atributo="dataHora" label="Data/Hora"  align="center" decorator="gov.pr.celepar.framework.taglib.grid.decorator.DataHora"/>
	    	<grid:campo atributo="acesso" label="Acesso"  align="center" decorator="gov.pr.celepar.sentinela.util.BooleanDecorator"/>
	   	</grid:table>
	</div>
</c:if>

<script language="javascript" type="text/javascript">
	function clearGrupo(){
		document.forms[0].codGrupo.value="";
	 	document.forms[0].nomeGrupo.value="";
	}
	
	function clearAutor(){
		document.forms[0].codAutor.value="";
	 	document.forms[0].nomeAutor.value="";
	}

	function AoSelecionarUsuarioPopup(codigo,nome){
	 	document.forms[0].codAutor.value=codigo;
	 	document.forms[0].nomeAutor.value=nome;
	 	document.forms[0].nomeAutor.disabled=true;
	 	document.forms[0].acao.value="";
	 }
	 
	 function AoSelecionarGrupoPopup(codigo,nome){
	 	document.forms[0].codGrupo.value=codigo;
	 	document.forms[0].nomeGrupo.value=nome;
	 	document.forms[0].nomeGrupo.disabled=true;
 		document.forms[0].acao.value="";
	 }

	function AoClicarPesquisar(){
		frm = document.forms[0];
		if(frm){
			frm.dataInicial.disabled=false;
			frm.dataFinal.disabled=false;
			frm.nomeGrupo.disabled=false;
			frm.nomeAutor.disabled=false;
			frm.action="pesquisaLogGrupoSistema.do";
			frm.acao.value="pesquisar";
			frm.submit();
		}
	}
	
	function AoClicarPrincipal(){
		frm = document.forms[0];
		if(frm){
			frm.action="principal.do";
			frm.submit();
		}
	}
</script>


</html:form>
